﻿#include "DBKey.h"
#include <QMap>
#include "Macro.h"

namespace DBKey
{
	//记录所有KEY
	static QMap<QString,const Item*> sItemMap;
	
    #define DEF_DB_KEY(name,save) Item name(#name,save);
    #include "DBKeyTable.h"
    #undef DEF_DB_KEY
	
	Item::Item(const char* _name, bool _save)
	: name(_name), save(_save)
	{
		sItemMap.insert(name,this);
	}
	
	const Item* Find(const QString& key){
		FAIL_RET_X(sItemMap.contains(key),0);
		return sItemMap.value(key);
	}
	bool CheckNeedSave(const QString& key){
		const Item* pItem = Find(key);
		return pItem?pItem->save:false;
	}
}
